﻿

'*******************************************************************
' Program: Data Center Visio Rack Tool
' Author: Albert E Edlund
' Date:
'
' Purpose:
'
'
'
'*******************************************************************


Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging


Imports System
Imports System.ComponentModel
Imports System.Collections.Generic




Public Class dc_Product
    Implements INotifyPropertyChanged


#Region "Events"

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private Sub OnPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub

#End Region

#Region " Constructor "

    Public Sub New()
        initProperties()
    End Sub

    Public Sub New(ByVal strUserId As String)
        initProperties()
        Me.m_prodlastedit = strUserId
    End Sub

#End Region

#Region " Enumerations "


    '
    ' these are the enumerated types and subtypes
    '
    Public Enum vnetType

        ptUnknown = -1
        ' needed a vnettype for components that are just holding a place for future
        ' use in a rack
        ptPlaceHolder = 0
        ' network active interacts with other devices 
        ptNetworkActive = 10
        ' network passive does not respond to network commands
        ptNetworkPassive = 20
        ' type of path
        ' --- hold for object selection
        ptNetworkLink = 30

        ' these aren't used since implementing operating systems
        ' but are still needed because of some legacy information in the database
        ptPlatformWintel = 40
        ptPlatformUnix = 50
        ptPlatformOther = 60

    End Enum


    '
    '
    '
    Public Enum vnetSubtype

        stUnknown = -1
        stDefault = 0
        stRouter = 11
        stSwitch = 12

        stAccessPoint = 13
        stFirewall = 14
        stLoadBalancer = 15
        stL7Firewall = 16
        stProbe = 17

        stRack = 21
        stPower = 22
        stPatchPanel = 23
        stDumbHub = 24
        stShelving = 25
        stSubComponent = 26
        stKVM = 27

        stWintelServer = 40

        stOtherPrinter = 62

    End Enum


    Public Enum View
        viewUnknown = -1
        viewFront = 1
        viewRear = 2
        viewTop = 3
        viewFull = 4
        viewCable = 5
        viewStatus = 6
    End Enum


#End Region

#Region " Properties and Fields "


    '
    ' field definitions
    '
    Private m_prodkey As Int32
    Public Const constProdKey As Int32 = -1
    Property prodKey() As Int32
        Get
            Return Me.m_prodkey
        End Get
        Set(ByVal value As Int32)
            Me.m_prodkey = value
            Me.OnPropertyChanged("prodKey")
        End Set
    End Property

    Private m_prodVendor As String
    Public Const constProdVendor As String = "none"
    Property prodVendor() As String
        Get
            Return Me.m_prodVendor
        End Get
        Set(ByVal value As String)
            Me.m_prodVendor = value
            Me.OnPropertyChanged("prodVendor")
        End Set
    End Property

    Private m_prodProduct As String
    Public Const constProdProduct As String = "none"
    Property prodProduct() As String
        Get
            Return Me.m_prodProduct
        End Get
        Set(ByVal value As String)
            If value Is Nothing Then
                m_prodProduct = constProdProduct
            Else
                Me.m_prodProduct = value
            End If
            Me.OnPropertyChanged("prodProduct")
        End Set
    End Property

    Private m_prodmodel As String
    Public Const constProdModel As String = "none"
    Property prodModel() As String
        Get
            Return Me.m_prodmodel
        End Get
        Set(ByVal value As String)
            Me.m_prodmodel = value
            Me.OnPropertyChanged("prodModel")
        End Set
    End Property

    Private m_prodpartnr As String
    Public Const constProdPartNr As String = "none"
    Property prodPartNr() As String
        Get
            Return Me.m_prodpartnr
        End Get
        Set(ByVal value As String)
            Me.m_prodpartnr = value
            Me.OnPropertyChanged("prodPartNr")
        End Set
    End Property

    Private m_prodstencil As String
    Public Const constProdStencil As String = "none"
    Property prodStencil() As String
        Get
            Return Me.m_prodstencil
        End Get
        Set(ByVal value As String)
            Me.m_prodstencil = value
            Me.OnPropertyChanged("prodStencil")
        End Set
    End Property

    Private m_prodmasterfront As String
    Public Const constProdMasterFront As String = "na"
    Property prodMasterFront() As String
        Get
            Return Me.m_prodmasterfront
        End Get
        Set(ByVal value As String)
            Me.m_prodmasterfront = value
            Me.OnPropertyChanged("prodMasterFront")
        End Set
    End Property

    Private m_prodmasterrear As String
    Public Const constProdMasterRear As String = "na"
    Property prodMasterRear() As String
        Get
            Return Me.m_prodmasterrear
        End Get
        Set(ByVal value As String)
            Me.m_prodmasterrear = value
            Me.OnPropertyChanged("prodMasterRear")
        End Set
    End Property

    Private m_prodMasterTop As String
    Public Const constprodMasterTop As String = "na"
    Property prodMasterTop() As String
        Get
            Return Me.m_prodMasterTop
        End Get
        Set(ByVal value As String)
            Me.m_prodMasterTop = value
            Me.OnPropertyChanged("prodMasterTop")
        End Set
    End Property

    Private m_prodMasterLogical As String
    Public Const constprodMasterLogical As String = "na"
    Property prodMasterLogical() As String
        Get
            Return Me.m_prodMasterLogical
        End Get
        Set(ByVal value As String)
            Me.m_prodMasterLogical = value
            Me.OnPropertyChanged("prodMasterLogical")
        End Set
    End Property

    Private m_prodslots As Integer
    Public Const constProdSlots As Integer = 1
    Property prodSlots() As Integer
        Get
            Return Me.m_prodslots
        End Get
        Set(ByVal value As Integer)
            If IsNumeric(value) Then
                Me.m_prodslots = CInt(value)
            Else
                Me.m_prodslots = constProdSlots
            End If
            Me.OnPropertyChanged("prodSlots")
        End Set
    End Property

    Private m_prodbtu As Double
    Public Const constProdBTU As Double = 0
    Property prodBTU() As Double
        Get
            Return Me.m_prodbtu
        End Get
        Set(ByVal value As Double)
            If IsNumeric(value) Then
                Me.m_prodbtu = CDbl(value)
            Else
                Me.m_prodbtu = constProdBTU
            End If
            Me.OnPropertyChanged("prodBTU")
        End Set
    End Property

    Private m_prodpower As Double 'kva
    Public Const constProdPower As Double = 0
    Property prodPower() As Double
        Get
            Return Me.m_prodpower
        End Get
        Set(ByVal value As Double)
            If IsNumeric(value) Then
                Me.m_prodpower = CDbl(value)
            Else
                Me.m_prodpower = constProdPower
            End If
            Me.OnPropertyChanged("prodPower")
        End Set
    End Property

    Private m_prodvoltage As Int32
    Public Const constProdVoltage As Int32 = 0
    Property prodVoltage() As Double
        Get
            Return Me.m_prodvoltage
        End Get
        Set(ByVal value As Double)
            If IsNumeric(value) Then
                Me.m_prodvoltage = CInt(value)
            Else
                Me.m_prodvoltage = constProdVoltage
            End If
            Me.OnPropertyChanged("prodVoltage")
        End Set
    End Property

    Private m_prodweight As Double ' lbs
    Public Const constProdWeight As Double = 0
    Property prodWeight() As Double
        Get
            Return Me.m_prodweight
        End Get
        Set(ByVal value As Double)
            If IsNumeric(value) Then
                Me.m_prodweight = CDbl(value)
            Else
                Me.m_prodweight = constProdWeight
            End If
            Me.OnPropertyChanged("prodWeight")
        End Set
    End Property

    Public Const constProdLastUpdate As Date = #1/1/2001#
    Private m_prodlastupdate As Date
    Property prodLastUpdate() As Date
        Get
            Return Me.m_prodlastupdate
        End Get
        Set(ByVal value As Date)
            Me.m_prodlastupdate = value
            Me.OnPropertyChanged("prodLastUpdate")
        End Set
    End Property

    Private m_prodlastedit As String
    Public Const constProdLastEdit As String = ""
    Property prodLastEdit() As String
        Get
            Return Me.m_prodlastedit
        End Get
        Set(ByVal value As String)
            If value Is Nothing Then
                Me.m_prodlastedit = constProdLastEdit
            Else
                Me.m_prodlastedit = value
            End If
            Me.OnPropertyChanged("prodLastEdit")
        End Set
    End Property

    Private m_prodcomments As String
    Public Const constProdComments As String = "none"
    Property prodComments() As String
        Get
            Return Me.m_prodcomments
        End Get
        Set(ByVal value As String)
            Me.m_prodcomments = value
            Me.OnPropertyChanged("prodComments")
        End Set
    End Property

    Private m_proderrorslots As Boolean
    Public Const constProdErrorSlots As Boolean = False
    Property prodErrorSlot() As Boolean
        Get
            Return Me.m_proderrorslots
        End Get
        Set(ByVal value As Boolean)
            Me.m_proderrorslots = value
            Me.OnPropertyChanged("prodErrorSlot")
        End Set
    End Property

    Private m_proderrorports As Boolean
    Public Const constProdErrorPorts As Boolean = False
    Property prodErrorPort() As Boolean
        Get
            Return Me.m_proderrorports
        End Get
        Set(ByVal value As Boolean)
            Me.m_proderrorports = value
            Me.OnPropertyChanged("prodErrorPort")
        End Set
    End Property

    Private m_proderrorgeneral As Boolean
    Public Const constProdErrorGeneral As Boolean = False
    Property prodErrorGeneral() As Boolean
        Get
            Return Me.m_proderrorgeneral
        End Get
        Set(ByVal value As Boolean)
            Me.m_proderrorgeneral = value
            Me.OnPropertyChanged("prodErrorGeneral")
        End Set
    End Property

    Private m_prodType As VnetType
    Public Const constprodType As VnetType = VnetType.ptUnknown
    Property prodType() As VnetType
        Get
            Return Me.m_prodType
        End Get
        Set(ByVal value As VnetType)
            ' Checks to see if the value passed is valid.
            If Not TypeDescriptor.GetConverter(GetType(VnetType)).IsValid(value) Then
                ' Throw New ArgumentException()
                value = VnetType.ptUnknown
            End If
            Me.m_prodType = value
            Me.OnPropertyChanged("prodType")
        End Set
    End Property

    Private m_prodSubtype As VnetSubtype
    Public Const constprodSubtype As VnetSubtype = VnetSubtype.stUnknown
    Property prodSubtype() As VnetSubtype
        Get
            Return Me.m_prodSubtype
        End Get
        Set(ByVal value As VnetSubtype)
            ' Checks to see if the value passed is valid.
            If Not TypeDescriptor.GetConverter(GetType(VnetSubtype)).IsValid(value) Then
                'Throw New ArgumentException()
                value = VnetSubtype.stUnknown
            End If
            Me.m_prodSubtype = value
            Me.OnPropertyChanged("prodSubtype")
        End Set
    End Property



#End Region

#Region " Methods "


    Public Sub initProperties()

        Try

            prodKey = constProdKey
            prodVendor = constProdVendor
            prodProduct = constProdProduct
            prodModel = constProdModel
            prodPartNr = constProdPartNr
            prodSlots = constProdSlots
            prodWeight = constProdWeight
            prodBTU = constProdBTU
            prodPower = constProdPower
            prodVoltage = constProdVoltage
            prodStencil = constProdStencil
            prodMasterFront = constProdMasterFront
            prodMasterRear = constProdMasterRear
            prodMasterTop = constprodMasterTop
            prodMasterLogical = constprodMasterLogical
            prodType = constprodType
            prodSubtype = constprodSubtype
            prodComments = constProdComments
            prodLastUpdate = Now()
            prodLastEdit = constProdLastEdit
            prodErrorSlot = False
            prodErrorPort = False
            prodErrorGeneral = False

        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub




#End Region


End Class

